import {defineStore} from 'pinia'
import {ref} from 'vue'
import {getUserInfoService} from '@/api/user.js'

export const useUserStore = defineStore('big-user',()=>{
  const token = ref('')
  const setToken = (newToken) => {
    token.value = newToken
  }

  const user = ref({})
  const getUser = async () => {
    const res = await getUserInfoService()
    user.value = res.data.data
  }
  const setUser = (newUser) => {
    user.value = newUser
  }
  return {
    token,
    setToken,
    user,
    getUser,
    setUser
  }
},
{
  persist: true
}
)